/**
* Created by ren on 2016/12/27.
*/
<template>
  <div
    :class="{'alert':true,'alert-notify':true,'notify':true,'success':status===1,'error':status===0}">
    <a class="close">×</a>
    <span>{{msg}}</span>
  </div>
</template>

<script>
  export default {
    name: 'notify',
    props: ['parentThis'],
    data: function () {
      return {
        status: 2,
        msg: ''
      }
    },
    updated: function () {
      setTimeout(() => {
        this.status = 2
        this.parentThis.notifyStatus = 2
      }, 3000)
    },
    watch: {
      'parentThis.notifyStatus': function (newVal) {
        if (newVal !== 2 && newVal.indexOf('|') > -1) {
          this.status = parseInt(newVal.toString().split('|')[0])
          this.msg = newVal.toString().split('|')[1]
        }
      }
    }
  }
</script>
